package com.tencent.sr.iris.activity.interfaces.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.tencent.sr.rmall.common.exception.TMallBizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * taskId
 */
@AllArgsConstructor
@Getter
public enum ActivityTaskIdEnum {

    //邀请有礼
    INVITE_GMV_TASK("INVITE_GMV_TASK", "邀请有礼GMV任务"),
    ;

    @JsonValue
    private final String code;
    private final String desc;

    @JsonCreator
    public static ActivityTaskIdEnum jsonCreator(String code) {
        ActivityTaskIdEnum activityIdEnum = getByCode(code);
        if (activityIdEnum == null) {
            throw new TMallBizException("任务id错误");
        }
        return activityIdEnum;
    }

    public static ActivityTaskIdEnum getByCode(String code) {
        for (ActivityTaskIdEnum staff : ActivityTaskIdEnum.values()) {
            if (staff.getCode().equals(code)) {
                return staff;
            }
        }

        return null;
    }
}
